<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Admin\LoginController as AdminLoginController;
use App\Http\Controllers\Admin\DashboardController as AdminDashboardController;
use App\Http\Controllers\Admin\UserController as AdminUserController;
use App\Http\Controllers\Admin\RoleController as AdminRoleController;
use App\Http\Controllers\Admin\CatalogController as AdminCatalogController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('admin/', function(){
    return redirect('admin/index');
});

//后台
Route::prefix('admin')->group(function(){

    Route::get('errorIndex', [AdminLoginController::class, 'errorIndex'])->name('admin/errorIndex');
    Route::get('loginIndex', [AdminLoginController::class, 'index'])->name('admin/loginIndex');
    Route::post('login', [AdminLoginController::class, 'login'])->name('admin/login');
    //arrow-bar-right
    Route::get('loginOut', [AdminLoginController::class, 'loginOut'])->name('admin/loginOut');

    Route::middleware(['auth.admin'])->group(function(){
        //box
        Route::get('index', [AdminDashboardController::class, 'index'])->name('admin/index');

//        管理员
        Route::prefix('user')->group(function(){
            //person
            Route::get('profile', [AdminUserController::class, 'profile'])->name('admin/user/profile');
            //pencil
            Route::get('editProfile', [AdminUserController::class, 'editProfile'])->name('admin/user/editProfile');
            Route::post('saveProfile', [AdminUserController::class, 'saveProfile'])->name('admin/user/saveProfile');

            //people
            Route::get('index', [AdminUserController::class, 'index'])->name('admin/user/index');
            Route::get('edit/{id?}', [AdminUserController::class, 'editUser'])->name('admin/user/edit');
            Route::post('save', [AdminUserController::class, 'saveUser'])->name('admin/user/save');
            Route::post('delete',[AdminUserController::class, 'deleteUser'])->name('admin/user/delete');
            Route::post('status', [AdminUserController::class, 'changeStatus'])->name('admin/user/status');
            Route::post('batchActions', [AdminUserController::class, 'batchActions'])->name('admin/user/batchActions');
        });

//      权限 house-fill
        Route::prefix('role')->group(function(){
            //person-check
            Route::get('index', [AdminRoleController::class, 'index'])->name('admin/role/index');
            Route::get('editRole', [AdminRoleController::class, 'editRole'])->name('admin/role/editRole');
            Route::post('saveRole', [AdminRoleController::class, 'saveRole'])->name('admin/role/saveRole');
            Route::get('changeRole', [AdminRoleController::class, 'changeRole'])->name('admin/role/changeRole');
            Route::get('deleteRole', [AdminRoleController::class, 'deleteRole'])->name('admin/role/deleteRole');
            Route::post('actionsRole',[AdminRoleController::class, 'actionsRole'])->name('admin/role/actionsRole');

            Route::get('editRules/{id?}', [AdminRoleController::class, 'editRules'])->name('admin/role/editRules');
            Route::post('saveRules', [AdminRoleController::class, 'saveRules'])->name('admin/role/saveRules');

            //grid
            Route::get('menuIndex', [AdminRoleController::class, 'menuIndex'])->name('admin/role/menuIndex');
            Route::get('menuEdit/{id?}', [AdminRoleController::class, 'menuEdit'])->name('admin/role/menuEdit');
            Route::post('menuSave', [AdminRoleController::class, 'menuSave'])->name('admin/role/menuSave');
            Route::post('menuDelete', [AdminRoleController::class, 'menuDelete'])->name('admin/role/menuDelete');
        });

        //产品，分类
        Route::prefix('catalog')->group(function(){
            //gift-fill
            Route::get('index', [AdminCatalogController::class, 'index'])->name('admin/catalog/index');
            Route::get('edit', [AdminCatalogController::class, 'edit'])->name('admin/catalog/edit');

            //list-ul
            Route::get('categoryIndex', [AdminCatalogController::class, 'categoryIndex'])->name('admin/catalog/categoryIndex');
            Route::get('categoryEdit', [AdminCatalogController::class, 'categoryEdit'])->name('admin/catalog/categoryEdit');
        });
    });

});
